package com.jerry.db.service;

import com.jerry.db.dao.BootRoleInfoMapper;
import com.jerry.db.domain.BootRoleInfo;
import com.jerry.db.domain.BootRoleInfoExample;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

@Service
public class BootRoleInfoService {
    @Resource
    BootRoleInfoMapper bootRoleInfoMapper;


    public Set<String> queryByIds(String[] roleIds){

        Set<String> roles = new HashSet<String>();
        if(roleIds.length == 0){
            return roles;
        }

        BootRoleInfoExample example = new BootRoleInfoExample();
        example.or().andIdIn(Arrays.asList(roleIds)).andIfEnabledEqualTo(true).andIsDelEqualTo(false);
        List<BootRoleInfo> roleList = bootRoleInfoMapper.selectByExample(example);

        for(BootRoleInfo role : roleList){
            roles.add(role.getRoleName());
        }

        return roles;
    }
}
